<?php

use yii\helpers\Html;
use common\widgets\ActiveForm;
use emhome\plupload\Plupload;
use kartik\datetime\DateTimePicker;
use common\models\teacher\Teacher;

/* @var $this  yii\web\View */
/* @var $model backend\modules\educater\models\TeacherForm */
/* @var $form common\widgets\ActiveForm */
?>
<?php
$form = ActiveForm::begin([
    'layout' => 'horizontal',
    'fieldConfig' => [
        'template' => "{label}\n{beginWrapper}\n{input}\n{error}\n{hint}\n{endWrapper}",
        'horizontalCssClasses' => [
            'label' => 'col-sm-2',
            'offset' => 'col-sm-offset-2',
            'wrapper' => 'col-sm-4',
            'error' => '',
            'hint' => '',
        ],
        'horizontalCheckboxTemplate' => "<div class=\"col-md-offset-2 col-md-4\">\n<label class=\"mt-checkbox mt-checkbox-outline\">\n{input}\n{labelTitle}<span></span>\n{endLabel}\n{error}\n{hint}\n</div>",
        'inlineRadioListTemplate' => "{label}\n<div class=\"col-md-4\">\n{input}\n{error}\n{hint}\n</div>",
        'inlineCheckboxListTemplate' => "{label}\n<div class=\"col-md-8\">\n{input}\n{error}\n{hint}\n</div>",
        'inline' => true,
    ],
    'options' => ['class' => 'form-horizontal form-bordered'],
]);
?>
<div class="form-body">
    <?= $form->field($model, 'number')->textInput() ?>
    <?= $form->field($model, 'name')->textInput() ?>
    <?= $form->field($model, 'nickname')->textInput() ?>
    <?= $form->field($model, 'gender')->radioList(null, ['remove_item_value' => 0]) ?>
    <?= $form->field($model, 'mobile')->textInput() ?>
    <?php if ($model->getIsNewRecord()): ?>
        <?= Html::activeHiddenInput($model, 'role_id') ?>
        <?= $form->field($model, 'password')->passwordInput() ?>
    <?php endif; ?>
    <?= $form->field($model, 'nation_id')->dropDownList() ?>
    <?=
    $form->field($model, 'birthday')->widget(DateTimePicker::className(), [
        'layout' => '{input}{picker}',
        'size' => 'medium',
        'type' => DateTimePicker::TYPE_INPUT,
        'pluginOptions' => [
            'minView' => 2,
            'autoclose' => true,
            'todayHighlight' => true,
            'format' => 'yyyy-mm-dd',
        ]
    ])
    ?>
    <?= $form->field($model, 'grade_id')->textInput() ?>
    <?=
    $form->field($model, 'avatar')->widget(Plupload::classname(), [
        'url' => ['/attachs/plupload'],
        'attachUrl' => Yii::getAlias('@attachUrl'),
        'resize' => ['width' => 200, 'height' => 200],
        'options' => [
            'multipart_params' => ['dir' => 'profile'],
        ],
    ])->hint('* 图片尺寸：200*200 仅是建议尺寸，此图片仅保持横条状即可', [
        'class' => 'font-yellow-gold sbold',
        'style' => 'margin-top:10px;font-size:12px'
    ])
    ?>

    <?=
    $form->field($model, 'status')->radioList(Teacher::getConstAttributeLabels('status', '<span></span>'))
    ?>
</div>
<div class="form-actions fluid">
    <div class="row">
        <div class="col-md-offset-2 col-md-4">
            <?= Html::submitButton('提交保存', ['class' => 'btn btn-success']) ?>
            <?= Html::a('Cancel', Yii::$app->request->referrer, ['class' => 'btn default']) ?>
        </div>
    </div>
</div>
<?php ActiveForm::end(); ?>